<?php

class Application_Model_DbTable_Log extends Zend_Db_Table_Abstract
{

    protected $_name = 'log';

    public function addLoginLog($adminId){
         
        $timeStamp = mktime(date('H'),date('i'), date('s')
                            ,date('m'),date('d'),date('y'));
        $dob_disp1=strftime('%Y-%m-%d %H:%M:%S',$timeStamp);
            
             $data=array(
                 'admin_id'=>$adminId,
                 'login_time'=>$dob_disp1
             );
            
             $this->insert($data);
           //  return $this->getAdapter()->lastInsertId();
    }
    public function getLastLog($id){
      $db=$this->getAdapter();
      $stmt = $db-> query("SELECT log_id from log where admin_id='$id' order by log_id desc");
      $row = $stmt->fetchAll();
      return $row[0]['log_id'];
    }
    public function updateLogOut($id){
        $timeStamp = mktime(date('H'),date('i'), date('s')
                            ,date('m'),date('d'),date('y'));
        $dob_disp1=strftime('%Y-%m-%d %H:%M:%S',$timeStamp);

    $data = array(
            'logout_time' => $dob_disp1
        );
        $this->update($data, 'log_id = ' . (int) $id);
    }
}

